﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_ShowList : System.Web.UI.Page
{
    public  string PRJ = "";
    protected void Page_Load(object sender, EventArgs e)
    {

        string strSql;
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            if (Request.Form["btnSubmit"] == "删除" && Request.Form["chk"] != null)
            {
                string  delShowId = Request.Form["chk"].ToString();
                strSql = "delete from show where ID in (" + delShowId + ")";
                Db db = new Db();
                db.Command(strSql);
                db.Close();
                 HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
                 HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "删除", "show", strSql, "../Agency/ShowList.aspx");

            }
            PRJ=Request.QueryString["projectid"].ToString();
            if (PRJ != "")
            {
                ShowDate();
            }
            
        }
    }

    /// <summary>
    /// 将数据绑定到datalist
    /// </summary>
    public void ShowDate()
    {

        
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "show";                                               //要查询的表明
        dbPage.Key = "ID";                                               //表的主键    
        dbPage.Where = " ShowProject=" + PRJ;                                           //查询条件    
        dbPage.SelectField = "ID, ShowName, ShowProject,case ShowSort when '1' then '开标公示' when '2' then '中标公示' When '3' Then '竞价公示' else '未知' end as ShowSort, ShowUrl";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 10;                                                    //没有显示记录条数   
        dbPage.OrderBy = "ID";                  //排序字段
        dbPage.OrderByIsDesc = true;
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        DlShow.DataSource = dr;
        DlShow.DataBind();
        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();

        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键



    }
}
